package com.bitcola.exchange.service;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

@Service
public class TimerService {
    @Autowired
    RedisTemplate<String,Object> redisTemplate;
    @Autowired
    KlineService klineService;


    @Scheduled(cron = "0 0 0 */1 * ?")
    public void setPriceAndGain()
    {
        BigDecimal gain= (BigDecimal) redisTemplate.opsForValue().get("exchange_yesterday_gain_temp");
        BigDecimal price=klineService.getMarketPrice("TSOL_USDT");
        redisTemplate.opsForValue().set("exchange_yesterday_gain",gain);
        redisTemplate.opsForValue().set("exchange_yesterday_price",price);



    }
}
